import request from '@/request/request'

// 获取账户流水列表
export function getAccountFlowList(params) {
  return request({
    url: '/finance/accountFlow/list',
    method: 'get',
    params
  })
}

// 获取账户流水详情
export function getAccountFlowDetail(id) {
  return request({
    url: `/finance/accountFlow/detail/${id}`,
    method: 'get'
  })
}

// 新增账户流水
export function addAccountFlow(data) {
  return request({
    url: '/finance/accountFlow/add',
    method: 'post',
    data
  })
}

// 修改账户流水
export function updateAccountFlow(data) {
  return request({
    url: '/finance/accountFlow/update',
    method: 'put',
    data
  })
}

// 删除账户流水
export function deleteAccountFlow(id) {
  return request({
    url: `/finance/accountFlow/delete/${id}`,
    method: 'delete'
  })
}

// 批量删除账户流水
export function batchDeleteAccountFlow(ids) {
  return request({
    url: '/finance/accountFlow/batchDelete',
    method: 'delete',
    data: { ids }
  })
}

// 导出账户流水
export function exportAccountFlow(params) {
  return request({
    url: '/finance/accountFlow/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 获取账户流水统计
export function getAccountFlowStats(params) {
  return request({
    url: '/finance/accountFlow/stats',
    method: 'get',
    params
  })
}

// 审核账户流水（假设用 update 接口，status: 1 表示已审核）
export function approveAccountFlow(id) {
  return request({
    url: '/finance/accountFlow/update',
    method: 'put',
    data: { id, status: 1 }
  })
}

// 批量审核账户流水（逐个审核）
export function batchApproveAccountFlow(ids) {
  return Promise.all(ids.map(id => approveAccountFlow(id)))
} 